<?php


/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

//接管路由
$api = app('Dingo\Api\Routing\Router');
$api->version('v1', function ($api) {
    $api->group(['namespace'=>'App\Api\Controllers'],function ($api){
        $api->post('smsCode', 'SmsCodeSendController@smsCode');//短信验证码

        //已支持的学校，校区,后台会用这个接口
        $api->get('schools', 'SchoolController@index');
        $api->get('campus', 'SchoolController@campus');

        $api->get('wxLogin', 'WxLoginController@wxLogin');//微信登录
        $api->get('snsapiUserinfoUrl', 'WxLoginController@snsapiUserinfoUrl');//微信认证链接
        $api->post('wechatPayback', 'OrderController@wechatPayback');//书籍交易微信支付回调
        $api->post('spreadWechatPayBack', 'SpreadController@spreadWechatPayBack');//推广助力金微信支付回调
        $api->get('spreadWechatPayBacktest', 'SpreadController@payCallBack');//推广助力金微信支付回调

        $api->post('jssdk', 'WechatController@jssdk');

    });

    //需要用户认证
    $api->group(['middleware' => 'api.auth','namespace'=>'App\Api\Controllers'], function ($api) {
        //更新用户字段
        $api->post('updateField', 'UserController@updateField');

        //订单
        $api->get('order', 'OrderController@index');//获取全部订单
        $api->post('orderUpdate/{id}', 'OrderController@updateField'); //取消订单
        $api->delete('order/{id}', 'OrderController@destory');//删除订单
        $api->delete('orderTruncate', 'OrderController@orderTruncate');//清空订单相关数据

        //我的
        $api->get('user', 'UserController@index');//用户信息
        $api->post('bindPhone', 'UserController@bindPhone');//绑定手机号
        $api->post('updateSchoolInfo', 'UserController@updateSchoolInfo');//更新学校信息
        $api->get('faq', 'UserController@faq');//客服中心
        $api->post('feedback', 'FeedbackController@store');//意见反馈


        //余额
        $api->get('balanceDetail', 'BalanceController@balanceDetail');//余额详细数据

        //首页
        $api->get('recommend', 'HomeController@recommend');//首页推荐数据
        $api->get('recommendMore', 'HomeController@recommendMore');//首页推荐数据
        $api->get('banner', 'HomeController@banner');//首页推荐数据
        $api->get('notice', 'NoticeController@index');//用户是否有未读的系统消息
        $api->get('noticeList', 'NoticeController@noticeList');//用户系统消息列表




        //购物车
        $api->post('cart', 'CartController@store');
        $api->get('cart', 'CartController@index');
        $api->put('cart', 'CartController@updateSelected');//结算时先更新数据库选中状态
        $api->delete('cart', 'CartController@destroy');//删除购物车中商品

        //书架列表
        $api->get('getDepotList/{shareCode}', 'DepotController@getDepotList');//书架列表

        //商品
        $api->get('goodsMore', 'GoodsController@goodsMore');//商品更多

        //微信相关


        //提现
        $api->get('withdraw', 'WithdrawController@index');//提现申请首页
        $api->post('withdraw', 'WithdrawController@store');//提现申请
        $api->put('withdraw', 'WithdrawController@update');//重新提交



        //需要学校信息和手机号
        $api->group(['middleware' => 'checkBaseInfo'], function ($api) {
            //书架
            $api->get('depot', 'DepotController@index');//书架
            $api->put('depotDetail/{id}', 'DepotController@update');//书架更新书籍信息
            $api->post('depotStore/{isbn}', 'DepotController@store');//增加书籍动作
            $api->get('depotShow/{isbn}', 'DepotController@depotShow');//增加书籍预览数据
            $api->get('depotDetail/{id}', 'DepotController@depotDetail');//书架

            //商品
            $api->get('goodsDetail/{id}', 'GoodsController@goodsDetail');//商品详情
            $api->get('goodsSearch', 'GoodsController@goodsSearch');//商品搜索

            //订单
            $api->get('confirmOrder', 'OrderController@confirmOrder');//确认订单
            $api->post('order', 'OrderController@store');//生成订单
            $api->get('cancelOrder/{order_id}', 'OrderController@cancelOrder');//买家取消订单
            $api->delete('order/{order_id}', 'OrderController@destory');//删除订单
            $api->get('confirmGetGoods/{order_user_id}', 'OrderController@confirmGetGoods');//确认收货
            $api->get('refund/{order_goods_id}', 'OrderController@refund');//买家申请退款
            $api->post('dealRefund', 'OrderController@dealRefund');//卖家处理退款
            $api->post('confirmSendGoods', 'OrderController@confirmSendGoods');//卖家输入交易码确认交易

            //校园推广大使
            $api->get('spread', 'SpreadController@index');//校园推广大使首页
            $api->get('spreadSign', 'SpreadController@spreadSign');//获取支付参数
            $api->get('spreadList', 'SpreadController@spreadList');//我推广的校友
            $api->get('becomeSpread', 'SpreadController@becomeSpread');//成为校园推广大使


            //我的
            $api->get('customer', 'UserController@customer');//我的客户

        });
    });

});
